<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/common.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
    <!-- <script src="/admin/js/token.js"></script>-->
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div style="text-align: center;">
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="test-table-demoReload" placeholder="输入账号、邮箱、电话" autocomplete="off">
                </div>

                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin search" lay-submit lay-filter="LAY-user-back-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                    </button>
                </div>
            </div>
        </div>



        <div class="layui-card-body">
            <table class="layui-hide" id="t" lay-filter="t"></table>

        </div>

    </div>
</div>
</body>
<script type="text/html" id="caozuo">
    <a class="layui-btn layui-btn-xs" lay-event="recharge">充值</a>
</script>

<script>
    var $ = layui.$;
    var table = layui.table;
    var form = layui.form;
    table.render({
        elem: '#t',
        id: 'tt',
        url: '/appadmin/getAPP_Admin',
        cols: [
            [{
                field: 'id',
                title: '序号',
                type:'numbers',
                align: 'center'
            },
                {
                    field: 'username',
                    title: 'App账号',
                    width: '20%',
                    align: 'center'
                },

                {
                    field: 'phone',
                    title: '电话',
                    width: '15%',
                    align: 'center'
                },
                {
                    field: 'mail',
                    title: '邮箱',
                    width: '20%',
                    align: 'center'
                },
                {
                    field: 'shenyu_time',
                    title: '剩余时长',
                    width: '9.5%',
                    align: 'center'
                },
                {
                    field: 'jiasu_time',
                    title: '使用加速时长',
                    width: '10%',
                    align: 'center'
                },
                {field: 'status',width: '10%',align : 'center', title:'状态',sort: true, templet: function (d) {
                        if (d.status==0) return "禁用";
                        else if (d.status==1) return "启用";
                    }},
                {
                    title: '操作',
                    align: 'center',
                    toolbar: '#caozuo',
                    fixed: 'right'
                }
            ]
        ],
        limit:40,
        page: true,
        done: (res, curr, count) => {
           // setTimeout(function () {
           //     table.reload('tt');
           // },60000)
        }
    });

    //监听工具条
    table.on('tool(t)', function (obj) {
        var data = obj.data
        if (obj.event === 'recharge') {
            $.ajax({
                type:"get",
                url:"/appadmin/getAppAdminInfo?id=" + data.id,
                success:function (res) {
                    if(res.code=200){
                        layer.open({
                            type: 2,
                            title:"充值",
                            skin:'layui-layer-molv',
                            area: ['90%', '90%'],
                            content: 'recharge.html?id='+data.id+'&username='+res.data.username+'&syTime='+res.data.shenyu_time, //这里content是一个普通的String
                            end: function(){
                            }
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                }
            })
        }
    });

    $('.test-table-operate-btn .layui-btn').on('click', function () {
        var type = $(this).data('type')
        active[type] ? active[type].call(this) : ''
    });

    $('.search').on('click',function () {
        var text = $('#test-table-demoReload').val();
        table.reload('tt',{
            where:{
                text:text
            },
            page:{
                curr:1
            }
        })
    })
</script>
</html>
